#include <stdio.h>
#include <stdlib.h>
#define  datatype int 
#include "BiTree.h"

int leafnodetotal(BiTreeNode*curr)
{
	if (curr == NULL)return 0;
	BiTreeNode* p = curr;
	if (p->leftchild == NULL && p->rightchild == NULL)
	{
		return 1;
	}
	else {
		return  (leafnodetotal(curr->leftchild) + leafnodetotal(curr->rightchild));
	}
}

int nodetotal(BiTreeNode* curr)
{
	if (curr == NULL)return 0;
	else {
		return (1 + nodetotal(curr->leftchild) + nodetotal(curr->rightchild));
	}
}

int leftchildtotal(BiTreeNode* curr)
{
	if (curr == NULL)return 0;
	else {
		if (curr->leftchild != NULL)
		{
			return (1 + leftchildtotal(curr->leftchild) + leftchildtotal(curr->rightchild));
		}
		else {
		return (leftchildtotal(curr->leftchild) + leftchildtotal(curr->rightchild));
		}
	}
}

int main()
{
	BiTreeNode* p;
	InitiateTree(&p);
	InsertLeftNode(p,5);
	InsertLeftNode(p->leftchild, 5);
	InsertRightNode(p, 10);
	InsertRightNode(p->rightchild, 10);
	InsertLeftNode(p->rightchild, 5);
	InsertRightNode(p->leftchild, 10);
	InsertLeftNode(p->leftchild->leftchild, 5);
	int a = leafnodetotal(p);
	printf("%d\n", a);
	int b = nodetotal(p);
	printf("%d\n", b);
	int c = leftchildtotal(p);
	printf("%d\n", c);
	return 0;
}